package com.gxgeek.dto;

import com.gxgeek.CoreConstants;
import groovy.lang.GroovyObject;
import lombok.Data;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author gaoxing
 * @create 2018-05-22 下午5:36
 */
@Data
public class RuleCondition {

    private long id;

    private long condId;

    private GroovyObject groovy;

    /**
     * 规则配置参数
     */
    private Map<String, String> condParams = new HashMap<>();

    private List<RuleConditionParam> condDimesions = new ArrayList<>();


    public boolean needCalucate() {
        return groovy.getMetaClass().getMethods()
                .stream()
                .anyMatch(p -> p.getName().equals(CoreConstants.Groovy.CALU));
    }

}
